package com.java.mapper;

import com.java.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface EmployeeMapper {
    // 查询全部员工
    @Select("select * from emp;")
    List<Employee> selectAllEmployee();

    // 新增员工
    @Insert("INSERT INTO `emp` VALUES (#{empno},#{ename}, #{job}, #{mgr}, #{hiredate},#{sal}, #{comm}, #{deptno});")
    int insertEmployee(Employee emp);

    // 修改员工信息
    @Update("update `emp`\n" +
            "        set ename   = #{ename},\n" +
            "            job=#{job},\n" +
            "            mgr=#{mgr},\n" +
            "            hiredate=#{hiredate},\n" +
            "            sal=#{sal},\n" +
            "            comm= #{comm},\n" +
            "            deptno  = #{deptno}\n" +
            "        where empno = #{empno};")
    int updateEmployee(Employee emp);

    // 删除员工
    @Delete("delete from emp where empno = #{empno};")
    int deleteEmployee(int empno);
}
